package net.hw.rpc;
 
import org.apache.avro.ipc.NettyTransceiver;
import org.apache.avro.ipc.specific.SpecificRequestor;
import rpc.service.MathService;
 
import java.net.InetSocketAddress;
 
public class Client {
    public static void main(String[] args) throws Exception {
        // 创建NettyTransceiver对象
        NettyTransceiver transceiver = new NettyTransceiver(new InetSocketAddress("127.0.0.1",6666));
        // 通过特定请求者获取客户端代理（参数1：服务接口的实例；参数2：收发器）
        MathService proxy = SpecificRequestor.getClient(MathService.class, transceiver);
        
        // 通过客户端代理实现远程过程调用
        int result = proxy.add(5, 8);

        // 输出结果
        System.out.println("result = " + result);

        transceiver.close();
    }
}
